package com.zcoj.service;

import com.zcoj.core.model.PageData;
import com.zcoj.core.model.PageWrap;
import com.zcoj.pojo.Dto.Contest;
import com.zcoj.pojo.Vo.ContestRegisterVO;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;

import java.util.List;

/**
 * Service定义
 * @author 剩xia的盛夏
 * @date 2023/02/24 16:16
 */
@CacheConfig(cacheNames ="ContestService" )
public interface ContestService {

    /**
     * 创建
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */

    @CacheEvict(value = "ContestService",allEntries = true)
    Integer create(Contest contest);

    /**
     * 主键删除
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */

    @CacheEvict(value = "ContestService",allEntries = true)
    Integer deleteById(Integer id);

    /**
     * 批量主键删除
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */

    @CacheEvict(value = "ContestService",allEntries = true)
    void deleteByIdInBatch(List<Integer> ids);

    /**
     * 主键更新
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */

    @CacheEvict(value = "ContestService",allEntries = true)
    Integer updateById(Contest contest);

    /**
     * 批量主键更新
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */
    @CacheEvict(value = "ContestService",allEntries = true)
    void updateByIdInBatch(List<Contest> contests);

    /**
     * 主键查询
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */

    @Cacheable(key = "#p0.toString()+'findById'")
    Contest findById(Integer id);

    /**
     * 条件查询单条记录
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */

    @Cacheable(key = "#p0.toString()+'findOne'")
    Contest findOne(Contest contest);

    /**
     * 条件查询
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */


    @Cacheable(key = "#p0.toString()+'findList'")
    List<Contest> findList(Contest contest);
  
    /**
     * 分页查询
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */

    @Cacheable(key = "#p0.toString()+'findPage'")
    PageData<Contest> findPage(PageWrap<Contest> pageWrap);

    @Cacheable(key = "#p0.toString()+'findPageVo'")
    PageData<Contest> findPageVo(PageWrap<Contest> pageWrap);

    Integer checkIsRegister(Integer cid);

    Integer submitRegister(ContestRegisterVO contestRegisterVO);


    public boolean hasOngoingContest();

    @Cacheable(key = "#p0.toString()+'getContestTime'")
    Contest getContestTime(Integer cid);


    @Cacheable(key = "'getContestIdAndTitle'")
    List <Contest> getContestIdAndTitle();

    /**
     * 条件统计
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */
    long count(Contest contest);


}
